package com.shinhye.autorollviewpager;

import android.content.Context;
import android.util.AttributeSet;

import java.util.List;

/**
 * 轮播图控件，支持本地图片和网络图片资源，支持图片标题
 *
 * @author wl
 * @since 2016/1/4 18:03
 */
public class AutoRollImagePager extends AutoRollViewPager {
    private List<String> imgurls;
    private int[] imgRess;

    public AutoRollImagePager(Context context) {
        super(context);
    }

    public AutoRollImagePager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public AutoRollImagePager(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    /**
     * 设置组图的网络地址
     *
     * @param imgurls
     */
    public void setImageUrl(List<String> imgurls) {
        this.imgurls = imgurls;
    }

    /**
     * 设置组图的本地资源
     *
     * @param imgRess
     */
    public void setImageResource(int[] imgRess) {
        this.imgRess = imgRess;
    }

    @Override
    public void showUp() {
        BaseRollAdapter adapter;
        if(imgurls != null) {
            adapter = new RollViewPagerAdapter(getContext(), imgurls);
        } else {
            adapter = new RollViewPagerAdapter(getContext(), imgRess);
        }
        setRollAdapter(adapter);
        super.showUp();
    }
}